// 引入 request 请求
import request from "@/request/request"
import requestmock from '@/request/requsetMock'

// 暴露出 req api 对象  只要引入req  调用里面的方法就是发送请求
export const req = {
    // 请求三级列表
    getCategoryList: () => {
        return request.get(`product/getBaseCategoryList`)
    },
    // 请求轮播图列表
    getBannerList: () => {
        return requestmock.get('/bannerlist')
    },
    // 请求floor列表
    getFloorList: () => {
        return requestmock.get('/floorlist')
    },
    getSearchList: (searchParams) => {
        return request.post('/list', searchParams)
    },
    getDetailInfo: (skuId) => {
        return request.get(`/item/${skuId}`)
    },
    getCartInfo: (skuId, skuNum) => {
        return request.post(`/cart/addToCart/${skuId}/${skuNum}`)
    },
    getShopCartList: () => {
        return request.get('cart/cartList')
    },
    changeGoodChecked: (skuID, isChecked) => {
        return request.get(`/cart/checkCart/${skuID}/${isChecked}`)
    },
    deleteGoodInfo: (skuId) => {
        return request.delete(`/cart/deleteCart/${skuId}`)
    },
    AllGoodChecked: (isChecked, skuIdList) => {
        return request.post(`/cart/batchCheckCart/${isChecked}`, skuIdList)
    },
    deleteAllGoods: (skuIdList) => {
        return request.delete('/cart/batchDeleteCart', { data: { skuIdList } })
    },
    getVerificationCode: (phone) => {
        return request.get(`/user/passport/sendCode/${phone}`)
    },
    register: (userInfo) => {
        return request.post(`/user/passport/register`, userInfo)
    },
    login: (userInfo) => {
        return request.post(`/user/passport/login`, userInfo)
    },
    getUserInfo: () => {
        return request.get(`/user/passport/auth/getUserInfo`)
    },
    logOut: () => {
        return request.get(`/user/passport/logout`)
    },
    getUserAddressList: () => {
        return requestmock.get('/addressList')
    },
    getOrderInfo: () => {
        return request.get(`/order/auth/trade`)
    },
    submitOrder: (tradeNo, orderInfo) => {
        return request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, orderInfo)
    },
    getPayInfo: (orderId) => {
        return request.get(`/payment/weixin/createNative/${orderId}`)
    },
    queryStatus: (orderId) => {
        return request.get(`/payment/weixin/queryPayStatus/${orderId}`)
    },
    getOrderList: (page, limit) => {
        return request.get(`/order/auth/${page}/${limit}`)
    }
}
